package jsqlite.JDBC2z;

import java.sql.ResultSetMetaData;
import java.sql.SQLException;

/* loaded from: classes2.dex */
public class JDBCResultSetMetaData implements ResultSetMetaData {
    private JDBCResultSet r;

    @Override // java.sql.ResultSetMetaData
    public String getCatalogName(int i) throws SQLException {
        return null;
    }

    @Override // java.sql.ResultSetMetaData
    public int getColumnDisplaySize(int i) throws SQLException {
        return 0;
    }

    @Override // java.sql.ResultSetMetaData
    public int getPrecision(int i) throws SQLException {
        return 0;
    }

    @Override // java.sql.ResultSetMetaData
    public int getScale(int i) throws SQLException {
        return 0;
    }

    @Override // java.sql.ResultSetMetaData
    public String getSchemaName(int i) throws SQLException {
        return null;
    }

    @Override // java.sql.ResultSetMetaData
    public boolean isAutoIncrement(int i) throws SQLException {
        return false;
    }

    @Override // java.sql.ResultSetMetaData
    public boolean isCaseSensitive(int i) throws SQLException {
        return false;
    }

    @Override // java.sql.ResultSetMetaData
    public boolean isCurrency(int i) throws SQLException {
        return false;
    }

    @Override // java.sql.ResultSetMetaData
    public boolean isDefinitelyWritable(int i) throws SQLException {
        return true;
    }

    @Override // java.sql.ResultSetMetaData
    public int isNullable(int i) throws SQLException {
        return 2;
    }

    @Override // java.sql.ResultSetMetaData
    public boolean isReadOnly(int i) throws SQLException {
        return false;
    }

    @Override // java.sql.ResultSetMetaData
    public boolean isSearchable(int i) throws SQLException {
        return true;
    }

    @Override // java.sql.ResultSetMetaData
    public boolean isSigned(int i) throws SQLException {
        return false;
    }

    @Override // java.sql.Wrapper
    public boolean isWrapperFor(Class cls) throws SQLException {
        return false;
    }

    @Override // java.sql.ResultSetMetaData
    public boolean isWritable(int i) throws SQLException {
        return true;
    }

    public JDBCResultSetMetaData(JDBCResultSet jDBCResultSet) {
        this.r = jDBCResultSet;
    }

    @Override // java.sql.ResultSetMetaData
    public String getColumnClassName(int i) throws SQLException {
        int i2 = i - 1;
        JDBCResultSet jDBCResultSet = this.r;
        if (jDBCResultSet == null || jDBCResultSet.tr == null || i2 < 0 || i2 >= this.r.tr.ncolumns) {
            return null;
        }
        if (this.r.tr instanceof TableResultX) {
            int i3 = ((TableResultX) this.r.tr).sql_type[i2];
            if (i3 != -5) {
                if (i3 == -3 || i3 == -2) {
                    return "[B";
                }
                switch (i3) {
                    case 4:
                        return "java.lang.Integer";
                    case 5:
                        return "java.lang.Short";
                    case 6:
                        return "java.lang.Float";
                    case 7:
                    case 8:
                        return "java.lang.Double";
                    default:
                        switch (i3) {
                            case 91:
                                return "java.sql.Date";
                            case 92:
                                return "java.sql.Time";
                            case 93:
                                return "java.sql.Timestamp";
                            default:
                                return "java.lang.String";
                        }
                }
            }
            return "java.lang.Long";
        }
        return "java.lang.String";
    }

    @Override // java.sql.ResultSetMetaData
    public int getColumnCount() throws SQLException {
        JDBCResultSet jDBCResultSet = this.r;
        if (jDBCResultSet == null || jDBCResultSet.tr == null) {
            return 0;
        }
        return this.r.tr.ncolumns;
    }

    @Override // java.sql.ResultSetMetaData
    public String getColumnLabel(int i) throws SQLException {
        int i2 = i - 1;
        JDBCResultSet jDBCResultSet = this.r;
        if (jDBCResultSet == null || jDBCResultSet.tr == null || i2 < 0 || i2 >= this.r.tr.ncolumns) {
            return null;
        }
        return this.r.tr.column[i2];
    }

    @Override // java.sql.ResultSetMetaData
    public String getColumnName(int i) throws SQLException {
        int indexOf;
        int i2 = i - 1;
        JDBCResultSet jDBCResultSet = this.r;
        String str = null;
        return (jDBCResultSet == null || jDBCResultSet.tr == null || i2 < 0 || i2 >= this.r.tr.ncolumns || (str = this.r.tr.column[i2]) == null || (indexOf = str.indexOf(46)) <= 0) ? str : str.substring(indexOf + 1);
    }

    @Override // java.sql.ResultSetMetaData
    public int getColumnType(int i) throws SQLException {
        int i2 = i - 1;
        JDBCResultSet jDBCResultSet = this.r;
        if (jDBCResultSet != null && jDBCResultSet.tr != null && i2 >= 0 && i2 < this.r.tr.ncolumns) {
            if (this.r.tr instanceof TableResultX) {
                return ((TableResultX) this.r.tr).sql_type[i2];
            }
            return 12;
        }
        throw new SQLException("bad column index");
    }

    @Override // java.sql.ResultSetMetaData
    public String getColumnTypeName(int i) throws SQLException {
        int i2 = i - 1;
        JDBCResultSet jDBCResultSet = this.r;
        if (jDBCResultSet != null && jDBCResultSet.tr != null && i2 >= 0 && i2 < this.r.tr.ncolumns) {
            if (this.r.tr instanceof TableResultX) {
                int i3 = ((TableResultX) this.r.tr).sql_type[i2];
                if (i3 != -5) {
                    if (i3 != -3) {
                        if (i3 != -2) {
                            switch (i3) {
                                case 4:
                                    return "integer";
                                case 5:
                                    return "smallint";
                                case 6:
                                    return "float";
                                case 7:
                                    return "real";
                                case 8:
                                    return "double";
                                default:
                                    switch (i3) {
                                        case 91:
                                            return "date";
                                        case 92:
                                            return "time";
                                        case 93:
                                            return "timestamp";
                                        default:
                                            return "varchar";
                                    }
                            }
                        }
                        return "binary";
                    }
                    return "varbinary";
                }
                return "bigint";
            }
            return "varchar";
        }
        throw new SQLException("bad column index");
    }

    @Override // java.sql.ResultSetMetaData
    public String getTableName(int i) throws SQLException {
        int i2 = i - 1;
        JDBCResultSet jDBCResultSet = this.r;
        if (jDBCResultSet == null || jDBCResultSet.tr == null || i2 < 0 || i2 >= this.r.tr.ncolumns) {
            return null;
        }
        String str = this.r.tr.column[i2];
        if (str != null) {
            int indexOf = str.indexOf(46);
            if (indexOf > 0) {
                return str.substring(0, indexOf);
            }
            return null;
        }
        return str;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public int findColByName(String str) throws SQLException {
        JDBCResultSet jDBCResultSet = this.r;
        if (jDBCResultSet != null && jDBCResultSet.tr != null) {
            for (int i = 0; i < this.r.tr.ncolumns; i++) {
                String str2 = this.r.tr.column[i];
                if (str2 != null) {
                    if (str2.compareToIgnoreCase(str) == 0) {
                        return i + 1;
                    }
                    int indexOf = str2.indexOf(46);
                    if (indexOf > 0 && str2.substring(indexOf + 1).compareToIgnoreCase(str) == 0) {
                        return i + 1;
                    }
                }
            }
        }
        throw new SQLException("column " + str + " not found");
    }

    @Override // java.sql.Wrapper
    public <T> T unwrap(Class<T> cls) throws SQLException {
        throw new SQLException("unsupported");
    }
}
